



class Solution:
    def __init__(self):
        pass




    def get_center(self, s, left, right):
        #向外扩展
        while 0<=left and right < len(s) and s[left] == s[right]:
            left -= 1
            right += 1
        #需要往内缩一个
        return left+1,right-1


    def run(self,s):
        start ,end = 0,0
        for i in range(len(s)):
            start1,end1 = self.get_center(s, i, i)
            #如果长度为奇数个
            start2,end2 = self.get_center(s, i, i + 1)
            if end1 - start1 > end -start:
                start,end = start1,end1
            if end2 - start2 > end -start:
                start,end = start2,end2
        return s[start:end+1]

if __name__ == '__main__':
    s = Solution()
    res = s.run('abbacdccd')
    print(res)
